package com.wwwc.index.web.servlet;

import java.io.*;
import java.awt.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.ServletRequestWrapper;
import java.net.*;
import com.wwwc.util.web.*;
import com.wwwc.index.web.ejb.database.*;
import com.wwwc.index.web.ejb.*;

public class PayPalNotifyServlet extends HttpServlet {
    private EJBDatabaseQuery ejbdb;
    private PaymentBean pBean;

    public void doGet(HttpServletRequest request, HttpServletResponse response)
    {
	doPost(request, response);
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response)
    {	
	try {
	    response.setContentType("text/html");
	    HttpSession session  = request.getSession(true);
	    PrintWriter out      = response.getWriter();
	    String  user_ip      = request.getRemoteAddr();

	    String action        = request.getParameter("aid");
	    if(action == null) {
		System.out.println("PayPalNotifyServlet:Erroe:101");
		return;
	    }

	    //==============================================================
	    // payPal notify
	    //==============================================================
	    
	    if(action != null && action.equals("0-2")) {
		if(pBean == null) {
		    pBean = new PaymentBean();
		}
		pBean.payPalVerify(request);
	    }
	}
	catch(IOException e) {
	    System.out.println("PayPalNotifyServlet:Error:401:"+e);
	}
    }
}
